package com.xbongbong.paas.toolbox.exception;

import com.xbongbong.pro.enums.ErrorCodeEnum;

import java.io.Serializable;

/**
 * runtime级别的异常，在切面前置通知中需要用到
 * @author youli.chen
 * @date 2018-7-6
 */
public class XbbRuntimeException extends RuntimeException implements Serializable {

    private static final long serialVersionUID = 5467151971571230735L;

    private Integer code;
    private String msg;

    public XbbRuntimeException() {
        super();
    }

    public XbbRuntimeException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public XbbRuntimeException(ErrorCodeEnum errorCodeEnum) {
        this(errorCodeEnum.getCode(), errorCodeEnum.getMsg());
    }

    public XbbRuntimeException(ErrorCodeEnum errorCodeEnum, String msg) {
        this(errorCodeEnum.getCode(), msg);
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

}